/***************************************************************************
 *   Copyright (C) 2009 by Marian Skvarek   *
 *   skvarek.marian@gmail.com   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A TrackICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef EASYSCORE_CORECSYMBOLNOTE_H
#define EASYSCORE_CORECSYMBOLNOTE_H

#include "CNoteGroup.h"
#include "CPositionList.h"

namespace easyscore
{
	namespace core
	{
                class CBar;
                class CTrack;
                class CPart;
                class CScore;

		class CNoteView;

		enum EAccidental
		{
                        eAccidentalNatural,
			eAccidentalSharp,
                        eAccidentalFlat,
                        eAccidentalNone
		};

                /**
                        Represents note group - a group of notes that are played at the same time.
			@author Marian Skvarek <skvarek.marian@gmail.com>
		*/
		class CNote
		{

//Members
			protected:
                                NOTE_POSITION mPosition;
				EAccidental mAccidental;
                                bool mIsGhost;
                                bool mIsActive;
				CNoteGroup *mParentNoteGroup;

                                CPositionList mPositionList;

				CNoteView *mView;

//Accessors
			public:
                                NOTE_VALUE getValue() { return mParentNoteGroup->getValue(); }
                                void setPosition ( NOTE_POSITION value ) { mPosition = value; updateView(); }
                                NOTE_POSITION getPosition() const { return mPosition; }
                                void setAccidental ( const EAccidental& value );
				EAccidental getAccidental() const { return mAccidental; }
                                bool getIsGhost() { return mIsGhost;}
                                void setIsActive(bool value);
                                bool getIsActive() { return mIsActive; }
				void setParentNoteGroup ( CNoteGroup* value ){mParentNoteGroup = value;}
				CNoteGroup* getParentNoteGroup() const { return mParentNoteGroup; }
                                CBar* getParentBar() const { return mParentNoteGroup->getParentBar(); }
                                CTrack *getParentTrack() { return mParentNoteGroup->getParentTrack(); }
                                CPart *getParentPart() { return mParentNoteGroup->getParentPart(); }
                                CScore *getParentScore() { return mParentNoteGroup->getParentScore(); }

                                CPositionList getPositionList() { updatePositionList(); return mPositionList; }

				CNoteView *getView() { return mView; }

//Constructors, Initialization & Destructors
			public:
                                CNote ( int position = 0 );
				void initialize();

				void clear();
				~CNote();

//Public methods
			public:
                                void remove();
                                NOTE_OCTAVE getOctave();
                                NOTE_PITCH getRelativePitch();
                                NOTE_PITCH getAbsolutePitch();
                                NOTE_PITCH getAbsoluteNotePitch();
                                void toggleGhost(){ mIsGhost = !mIsGhost; }

				bool hasView() { return mView != 0; }
				void createView();
				void destroyView();
	
//Protected methods
			protected:
                                NOTE_POSITION getAbsolutePosition();
                                void updatePositionList();
                                NOTE_PITCH getAccidentalPitchShift();

                                void updateView();


		};
	}//namespace core
}//namespace easyscore

#endif
